package kltn.audioguidetravel;

import java.io.IOException;

import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class DetailActivity extends Activity{

	private MediaPlayer mediaPlayer;
	private ImageButton ibPlay;
	String url;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_detail);
		initial();
	}
	public void	initial() {
		url=getIntent().getStringExtra("urlAudio");
		ibPlay= (ImageButton) findViewById(R.id.ibPlay);
		ibPlay.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (mediaPlayer.isPlaying())
					mediaPlayer.pause();
				else
					mediaPlayer.start();
			}
		});
		//String url = "http://k007.kiwi6.com/hotlink/5t8ocggsgt/Ao_Giac_-_Tuan_Hung.mp3";
		mediaPlayer = new MediaPlayer();
	    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
	    try {
			mediaPlayer.setDataSource(url);
			mediaPlayer.prepare(); // might take long! (for buffering, etc)
			
		} catch (IllegalArgumentException | SecurityException
				| IllegalStateException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			    
	}
	
}
